/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function Radio(){

    this.like = function(name, id) {
        
            this.name = name;
            this.id = id;
                
            var like = $("#"+name).val();
            var commid = id;
            var dataString = 'like=1' + '&commid=' + commid;

            if(like=='' || commid=='')
            {
                $('.success').fadeOut(200).hide();
                $('.error').fadeOut(200).show();
            }
            else
            {
                $.ajax(
                
                {
                    
                    type: "POST",
                    url: "templates/formhandler.php",
                    data: dataString,
                    success: function(){
                        $('.success').fadeIn(200).show();
                        $('.error').fadeOut(200).hide();
                        
                        $('#comment'+id).load("templates/singlecomment.php?id="+id);
                        
                    }
                });
            }
            return false;
    }
    
    
    
     this.dislike = function(name, id) {
         
        this.name = name;
        this.id = id;
        
            var dislike = $("#"+name).val();
            var commid = id;

            var dataString = 'like=0' + '&commid=' + commid;

            if(dislike=='' || commid=='')
            {
                $('.success').fadeOut(200).hide();
                $('.error').fadeOut(200).show();
            }
            else
            {
                $.ajax({
                    type: "POST",
                    url: "templates/formhandler.php",
                    data: dataString,
                    success: function(){
                        $('.success').fadeIn(200).show();
                        $('.error').fadeOut(200).hide();
                        $('#comment'+id).load("templates/singlecomment.php?id="+id);
                        
                    }
                });
            }
            return false;
     }
}

var rad = new Radio;

